/*
 License
 
 Copyright © 2012 Kevin Kimmich
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights to 
 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 the Software, and to permit persons to whom the Software is furnished to do so, 
 subject to the following conditions:
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

/**
 @file
 Exported methods and types for using the library to run a web client.
 */

#ifndef _kuato_client_h
#define _kuato_client_h

#ifdef __cplusplus
extern "C" {
#endif
	
#include "kuato_types.h"
	
	/**
	 Do a get request. Return NULL on failure, or a method object on success. Call destroy_method() to free the
	 resources associated with the method.
	 @param ctx A client connection context, created with create_client_context().
	 @param host The host string--an IP address or a domain name.
	 @param url The URL.
	 @param headers Additional headers. Set to NULL for no headers.
	 @param body The request body. Set tp NULL for no body.
	 */
	method* http_client_get(connection_context* ctx, char* host,char* url, stream* headers, stream* body);
	
#ifdef ENABLE_LIBXML
	/**
	 Post an XML document to the server connected through ctx. Return NULL on failure or a method object on success.
	 Call destroy_method() to free the resources associated with the method.
	 @param ctx The connection context, created with create_client_context().
	 @param flags One flag is currently defined PARSE_RESPONSE. Set the flag to have the response parsed by libxml2.
	 @param headers Headers to add to the request.
	 @param doc The libxml2 XML document.
	 */
	method* http_client_post_doc(connection_context* ctx, uint32_t flags, stream* headers, xmlDocPtr doc);
#endif	
	/**
	 Post a string to the server connected through ctx. Return NULL on failure or a method object on success.
	 Call destroy_method() to free the method object.
	 @param ctx The connection context, created with create_client_context().
	 @param flags One flag is currently defined PARSE_RESPONSE. Set the flag to have the response parsed by libxml2.
	 @param content_type The content type of the body.
	 @param headers Headers to add to the request.
	 @param doc The libxml2 XML document.
	 */
	method* http_client_post_printf(connection_context* ctx,uint32_t flags, char* content_type, stream* headers, const char* format,...);
	
	/**
	 Post a stream to the server connected through ctx. Return NULL on failure, or a method object on success. Call destroy_method()
	 to free the resources associated with the method.
	 @param ctx The connection context, created with create_client_context().
	 @param flags One flag is currently defined PARSE_RESPONSE. Set the flag to have the response parsed by libxml2.
	 @param content_type The content type of the body.
	 @param headers Headers to add to the request.
	 @param stream The body.
	 */
	method* http_client_post_stream(connection_context* ctx, uint32_t flags, char* content_type, stream* headers, stream* body);
	
#ifdef __cplusplus
}
#endif

#endif
